// Christophe Coenraets, christophe@coenraets.org - http://coenraets.org
package com.salesbuilder.dao
{
	import mx.collections.ArrayCollection;
	
	public class BaseDAO
	{
		
		public function getList(sql:String, params:Array=null, startRow:int=0, pageSize:int=0):ArrayCollection
		{
           	return new ArrayCollection(); 		
		}
		
		public function getItem(sql:String, id:*):Object
		{
			var list:ArrayCollection = getList(sql, [id]);
			if (list && list.length == 1)
			{
				return list.getItemAt(0);
			}
			else
			{
				return null;
			}
		}

		public function executeUpdate(sql:String, params:Array=null):int
		{
			return 0;
		}

		public function createItem(sql:String, params:Array=null):int
		{
            return 0;
		}
		
		protected function processRow(row:Object):Object
		{
			throw new Error("You need to override processRow() in your concrete DAO");
		}
		
	}
}